﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SHeli : SFuncBase
{
    public float K = 10;
    public float RopeLength = 4;
    public SCollider Head;
    public SCollider Bottom;
    public override void SFixedUpdate()
    {
        base.SFixedUpdate();
        var l = Vector2.Distance(Head.transform.position, Bottom.transform.position) - RopeLength;
        if (l > 0)
        {
            var vtr = Head.transform.position - Bottom.transform.position;
            var angle = Mathf.Atan2(vtr.y, vtr.x) / Mathf.PI * 180f;
            Debug.Log("Angle is " + angle);

            Head.AddForceAtWordPosition(Head.transform.position,180f+angle, K * l);
            Bottom.AddForceAtWordPosition(Bottom.transform.position, angle, K * l);

        }
    }
   

}